package cn.com.nes.site.entity.em;

import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 工单状态
 */
public enum OrderWorkTypeEnum {
    /**
     * 调试
     */
    _0("31", "调试"),
    /**
     * 上门维修
     */
    _1("32", "上门维修"),
    /**
     * 上门维修
     */
    _2("34", "上门安装"),
    ;

    private String key;
    private String val;

    OrderWorkTypeEnum(String key, String val){
        this.key = key;
        this.val = val;
    }

    public String getVal() {
        return val;
    }

    public String getKey(){
        return key;
    }

    public static String getVal(int key) {
        if (ObjectUtil.isNull(key)) return StrUtil.EMPTY;
        Map<String, String> map = Arrays.stream(values())
                .collect(Collectors.toMap(OrderWorkTypeEnum::getKey, OrderWorkTypeEnum::getVal));
        return map.get(String.valueOf(key));
    }
}
